//
//  EditPersonTableViewController.m
//  PeopleFinder
//
//  Created by Mark Pavlidis on 1/30/2010.
//  Copyright 2010 Pavlidis Consulting. All rights reserved.
//

#import "EditPersonTableViewController.h"


@implementation EditPersonTableViewController

/*
- (id)initWithStyle:(UITableViewStyle)style {
    // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
    if (self = [super initWithStyle:style]) {
    }
    return self;
}
*/

/*
- (void)viewDidLoad {
    [super viewDidLoad];

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
*/

/*
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}
*/
/*
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}
*/
/*
- (void)viewWillDisappear:(BOOL)animated {
	[super viewWillDisappear:animated];
}
*/
/*
- (void)viewDidDisappear:(BOOL)animated {
	[super viewDidDisappear:animated];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


#pragma mark Table view methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 9;
}


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
	switch (section) {
		case 0:
			return 2;
		case 1:
			return 6;
		case 2:
			return 1;
		case 3:
			return 1;
		case 4:
			return 3;
		case 5:
			return 1;
		case 6:
			return 1;
		case 7:
			return 1;
		case 8:
			return 1;
		default:
			return 0;
	}
	
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
	switch (section) {
		case 0:
			return NSLocalizedString(@"Name",nil);
		case 1:
			return NSLocalizedString(@"Home Address",nil);
		case 2:
			return NSLocalizedString(@"Description",nil);
		case 3:
			return NSLocalizedString(@"Photo",nil);
		case 4:
			return NSLocalizedString(@"Source",nil);
		case 5:
			return NSLocalizedString(@"Status",nil);
		case 6:
			return NSLocalizedString(@"Message",nil);
		case 7:
			return NSLocalizedString(@"Last Known Location",nil);
		case 8:
			return NSLocalizedString(@"Have you had contact after the quake?",nil);
		default:
			return nil;
	}
}

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
	switch (section) {
		case 0:
		case 4:
		case 6:
		case 8:
			return NSLocalizedString(@"Required",nil);
		default:
			return nil;
	}
	
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
	
	UITableViewCell *cell = nil;

	switch (indexPath.section) {
		case 0:
		case 1:
		case 4:
		{
			static NSString *CellValue2Identifier = @"CellValue2";
			cell = [tableView dequeueReusableCellWithIdentifier:CellValue2Identifier];
			if (cell == nil) {
				cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellValue2Identifier] autorelease];
			}			
			break;
		}
		default:
		{
			static NSString *CellDefaultIdentifier = @"CellDefault";
			cell = [tableView dequeueReusableCellWithIdentifier:CellDefaultIdentifier];
			if (cell == nil) {
				cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellDefaultIdentifier] autorelease];
			}			
			break;
		}
	}
    
    // Set up the cell...
	cell.textLabel.text = cell.detailTextLabel.text = @"";
	switch (indexPath.section) {
		case 0:
			switch (indexPath.row) {
				case 0:
					cell.textLabel.text = NSLocalizedString(@"Given",nil);
					cell.detailTextLabel.text = nil;
					break;
				case 1:
					cell.textLabel.text = NSLocalizedString(@"Family",nil);
					cell.detailTextLabel.text = nil;
					break;
			}
			break;
		case 1:
			switch (indexPath.row) {
				case 0:
					cell.textLabel.text = NSLocalizedString(@"Street",nil);
					cell.detailTextLabel.text = nil;
					break;
				case 1:
					cell.textLabel.text = NSLocalizedString(@"District",nil);
					cell.detailTextLabel.text = nil;
					break;
				case 2:
					cell.textLabel.text = NSLocalizedString(@"City",nil);
					cell.detailTextLabel.text = nil;
					break;
				case 3:
					cell.textLabel.text = NSLocalizedString(@"State",nil);
					cell.detailTextLabel.text = nil;
					break;
				case 4:
					cell.textLabel.text = NSLocalizedString(@"Country",nil);
					cell.detailTextLabel.text = nil;
					break;					
				case 5:
					cell.textLabel.text = NSLocalizedString(@"Postal Code",nil);
					cell.detailTextLabel.text = nil;
					break;					
			}
			break;
		case 2:
			switch (indexPath.row) {
				case 0:
					break;
				default:
					break;
			}
			break;
		case 3:
			switch (indexPath.row) {
				case 0:
					break;
				default:
					break;
			}
			break;
		case 4:
			switch (indexPath.row) {
				case 0:
					cell.textLabel.text = NSLocalizedString(@"Name",nil);
					cell.detailTextLabel.text = nil;
					break;
				case 1:
					cell.textLabel.text = NSLocalizedString(@"Phone",nil);
					cell.detailTextLabel.text = nil;
					break;
				case 2:
					cell.textLabel.text = NSLocalizedString(@"Email",nil);
					cell.detailTextLabel.text = nil;
					break;
			}
			break;
		case 5:
			switch (indexPath.row) {
				case 0:
					break;
				default:
					break;
			}
			break;
		case 6:
			switch (indexPath.row) {
				case 0:
					break;
				default:
					break;
			}
			break;
		case 7:
			switch (indexPath.row) {
				case 0:
					break;
				default:
					break;
			}
			break;
		case 8:
			switch (indexPath.row) {
				case 0:
					break;
				default:
					break;
			}
			break;
	}
	cell.textLabel.minimumFontSize = 8.0;
	cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
	
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here. Create and push another view controller.
	// AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil];
	// [self.navigationController pushViewController:anotherViewController];
	// [anotherViewController release];
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/


/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/


/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/


/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/


- (void)dealloc {
    [super dealloc];
}


@end

